package com.daxia.bumall.model;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.springframework.format.annotation.DateTimeFormat;

/**
 * Product
 */
@Entity
@Table(name = "product") 
public class Product extends BaseModel {
	/**
	 * id
	 */
	@Id
	@GeneratedValue
	@Column(name = "id")
    private Long id;
	private String headImage;
	private Integer pinguanType;
	/**
	 * 店铺
	 */
	@ManyToOne
	@JoinColumn(name = "store_id")
    private Store store;
	@ManyToOne
	@JoinColumn(name = "user_id")
    private User user;
	
	private Integer status;
	/**
	 * 商品名称
	 */
	@Column(name = "name")
    private String name;
	/**
	 * 副标题
	 */
	@Column(name = "subTitle")
    private String subTitle;
	/**
	 * 商品分类
	 */
	@ManyToOne
	@JoinColumn(name = "ProductCategory_id")
    private ProductCategory productCategory;
	/**
	 * 单位
	 */
	@Column(name = "unit")
    private String unit;
	/**
	 * 上下架状态，0上架，1下架
	 */
	@Column(name = "sellingStatus")
    private Integer sellingStatus;
	/**
	 * 是否首页推荐
	 */
	@Column(name = "isRecommend")
    private Boolean isRecommend;
	
	@Column(name = "isNew")
    private Boolean isNew;
	/**
	 * 品牌
	 */
	@ManyToOne
	@JoinColumn(name = "brand_id")
    private Brand brand;
	/**
	 * 详情（图文详情）
	 */
	@Column(name = "details")
    private String details;
	/**
	 * 上传时间
	 */
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")	
	@Column(name = "createTime")
    private Date createTime;
	/**
	 * 最后更新时间
	 */
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")	
	@Column(name = "lastUpdateTime")
    private Date lastUpdateTime;
	/**
	 * 图片，数组，用逗号隔开
	 */
	@Column(name = "images")
    private String images;
	
	@OneToMany(mappedBy = "product", cascade=CascadeType.REMOVE)
	//@OrderBy(value  = "level ASC, seq ASC")
	private List<Specification> specifications;
	
	@OneToMany(mappedBy = "product")
	private List<DesignProduct> designProducts;
	
	/**
	 * 总销量
	 */
	private Integer totalSold = 0;
	
	/**
	 * 所有规格的达达订货编码+工厂编码拼起来的字符串，只是为了查询方便的
	 */
	private String codes; 
	private boolean deleted;
	public Long getId() {
    	return id;
    }
	
    public void setId(Long id) {
    	this.id = id;
    }
	
	public Store getStore() {
    	return store;
    }
	
    public void setStore(Store store) {
    	this.store = store;
    }
	
	public String getName() {
    	return name;
    }
	
    public void setName(String name) {
    	this.name = name;
    }
	
	public String getSubTitle() {
    	return subTitle;
    }
	
    public void setSubTitle(String subTitle) {
    	this.subTitle = subTitle;
    }
	
	public ProductCategory getProductCategory() {
    	return productCategory;
    }
	
    public void setProductCategory(ProductCategory productCategory) {
    	this.productCategory = productCategory;
    }
	
	public String getUnit() {
    	return unit;
    }
	
    public void setUnit(String unit) {
    	this.unit = unit;
    }
	
	public Integer getSellingStatus() {
    	return sellingStatus;
    }
	
    public void setSellingStatus(Integer sellingStatus) {
    	this.sellingStatus = sellingStatus;
    }
	
	public Boolean getIsRecommend() {
    	return isRecommend;
    }
	
    public void setIsRecommend(Boolean isRecommend) {
    	this.isRecommend = isRecommend;
    }
	
	public Brand getBrand() {
    	return brand;
    }
	
    public void setBrand(Brand brand) {
    	this.brand = brand;
    }
	
	public String getDetails() {
    	return details;
    }
	
    public void setDetails(String details) {
    	this.details = details;
    }
	
	public Date getCreateTime() {
    	return createTime;
    }
	
    public void setCreateTime(Date createTime) {
    	this.createTime = createTime;
    }
	
	public Date getLastUpdateTime() {
    	return lastUpdateTime;
    }
	
    public void setLastUpdateTime(Date lastUpdateTime) {
    	this.lastUpdateTime = lastUpdateTime;
    }
	
	public String getImages() {
    	return images;
    }
	
    public void setImages(String images) {
    	this.images = images;
    }

	public String getHeadImage() {
		return headImage;
	}

	public void setHeadImage(String headImage) {
		this.headImage = headImage;
	}

	public List<Specification> getSpecifications() {
		return specifications;
	}

	public void setSpecifications(List<Specification> specifications) {
		this.specifications = specifications;
	}

	public Integer getTotalSold() {
		return totalSold;
	}

	public void setTotalSold(Integer totalSold) {
		this.totalSold = totalSold;
	}

	public Integer getPinguanType() {
		return pinguanType;
	}

	public void setPinguanType(Integer pinguanType) {
		this.pinguanType = pinguanType;
	}

	public Boolean getIsNew() {
		return isNew;
	}

	public void setIsNew(Boolean isNew) {
		this.isNew = isNew;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public List<DesignProduct> getDesignProducts() {
		return designProducts;
	}

	public void setDesignProducts(List<DesignProduct> designProducts) {
		this.designProducts = designProducts;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public String getCodes() {
		return codes;
	}

	public void setCodes(String codes) {
		this.codes = codes;
	}

	public boolean isDeleted() {
		return deleted;
	}

	public void setDeleted(boolean deleted) {
		this.deleted = deleted;
	}
	
}
